package com.example.orderform.dao;

import com.example.orderform.vo.Order;
import com.example.orderform.vo.Refund;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface ReceivedMapper {


    @Select("select * from order_copy1 where orderstatus='卖家已发货' and userid=${userid} LIMIT #{q},#{j}")
    List<Order> receivedchals(int q,int j,int userid);

    @Select("select count(*) from order_copy1 where orderstatus='卖家已发货' and userid=#{userid}")
    int rececha(int userid);

    @Select("select * from order_copy1 where orderid='${orderid}'")
    Order orderxq(int orderid);


    @Select("select * from order_copy1 where ordernumber='${ordernumber}'")
    List<Order> receordernumber(@Param("ordernumber") String ordernumber);

    @Update("update `order_copy1` set orderstatus='退款中的订单',reason='${reason}' where ordernumber='${ordernumber}'")
    int tuikuang(String ordernumber,String reason);

    @Select("select * from order_copy1 where orderstatus='退款中的订单' and userid=${userid}")
    List<Order> tuikuancha(int userid);


    @Update("update `order_copy1` set orderstatus='评价',statusbutton='评价' where orderid='${orderid}'")
    int shouhuogai(int orderid);


    @Insert("insert into `order_copy2`(ordernumber,servicetype,cargostatus,price,refundreason,refundinstructions,shoopname,ordercolor,ordersieze,picture,updatime) values('${ordernumber}','${servicetype}','${cargostatus}','${price}','${refundreason}','${refundinstructions}','${shoopname}','${ordercolor}','${picture}','now()')")
    int addrece(@Param("ordernumber")String ordernumber,
                    @Param("servicetype")String servicetype,
                    @Param("cargostatus")String cargostatus,
                    @Param("price")String price,
                    @Param("refundreason")String refundreason,
                    @Param("refundinstructions")String refundinstructions,
                    @Param("shoopname")String shoopname,
                    @Param("ordercolor")String ordercolor,

                    @Param("picture")String picture);



    //收货  同意退款
    @Update("update order_copy2 set tkstatus='退款成功' where id='${id}' ")
    int updashouhuotongyi(int id);

    @Update("update order_copy1 set orderstatus='退款成功' where orderid='${orderid}' ")
    int updacopytongyi(int orderid);

    //收货 不同意退款
    @Update("update order_copy1 set orderstatus='卖家已发货' where orderid='${orderid}' ")
    int updashouhuobutongyi(int orderid);

    //
    @Select("select * from order_copy2 where tkstatus='退款成功'")
    List<Refund> seleshouhuotongyi();


    @Select("select * from order_copy2 where tkstatus='退款中的订单'")
    List<Refund> seleshouhuo();


}
